<?php
$page = 1;
if(isset($_GET['page'])) {
	$page = $_GET['page'];
}

$arrcountrows = getRowsTLCTIndex();
$sumrecord = $arrcountrows[0][0];
$numrecord = 12;
$pageNumber = intval(($sumrecord / $numrecord));
if(($sumrecord % $numrecord) != 0) {
	$pageNumber++;
}

if($pageNumber == 0) {
	$pageNumber = 1;	
}

if($page > $pageNumber) {
	$page = $pageNumber;
}
$products = getTLCTsLimitIndex(($page-1)*$numrecord, $numrecord);
?>
<div itemscope itemtype="" id="crumbs"> <a class="crumbs-home" itemprop="breadcrumb" href="/">Home</a> » <span class="current">Tài Liệu Chống Thấm</span></div>
<div class="page-head">
	<h2 class="page-title">Trang chuyên mục <span> Tài Liệu Chống Thấm</span></h2>
    <a class="rss-cat-icon ttip" title="Feed Subscription" href="#">Feed Subscription</a>
    <div class="stripe-line"></div>
    <div class="clear"></div>
    <div class="archive-meta"></div>
</div>

<div class="post-listing">

<?php
foreach ($products as $entry) {
?>	
	<article class="item-list">
		<h2><a href="/tai-lieu-chong-tham/<?php echo($entry[0]); ?>/<?php echo(rewriteTextUrl(stripUnicode($entry[1]))); ?>.html" title="<?php echo($entry[1]); ?>" rel="bookmark"><?php echo($entry[1]); ?></a></h2>
		<p class="post-meta">
        	<span><?php echo(int_to_date($entry[5])); ?></span>
		</p>
		<div class="post-thumbnail">
			<a href="/tai-lieu-chong-tham/<?php echo($entry[0]); ?>/<?php echo(rewriteTextUrl(stripUnicode($entry[1]))); ?>.html" title="<?php echo($entry[1]); ?>" rel="bookmark">
				<img width="168" height="108" src="<?php echo($entry[6]); ?>" class="attachment-thumbnail" alt="<?php echo($entry[1]); ?>" />
			</a>
		</div><!-- post-thumbnail /-->
        
		<div class="entry">
			<p><?php echo($entry[2]); ?> ...			<a class="more-link" href="/tai-lieu-chong-tham/<?php echo($entry[0]); ?>/<?php echo(rewriteTextUrl(stripUnicode($entry[1]))); ?>.html">Chi Tiết &raquo;</a></p>
		</div>
        <div class="clear"></div>
	</article><!-- .item-list -->
<?php 
}
?>	
	<!-- .item-list -->
	
</div>
<div class="pagination">
	<span class="pages">Trang <?php echo($page); ?>/<?php echo($pageNumber); ?></span>
    <?php
	$i = 1;
	for ($i = 1; $i <= $pageNumber; $i++) {
		if ($page == $i) {
			?>
    <span class="current"><?php echo($i); ?></span>        
            <?php
		} else {
			?>
    <a href="/tailieuchongtham/page/<?php echo($i); ?>.html" class="page" title="<?php echo($i); ?>"><?php echo($i); ?></a>
            <?php
		}
	}
	
	if ($page != $pageNumber) {
	?>
    <span id="tie-next-page">
    	<a href="/tailieuchongtham/page/<?php echo(($page + 1)); ?>.html" >&raquo;</a>
	</span>
    <?php 
	}
	?>
</div>